package com.landi.logger;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.landi.logger.utils.LogcatUtil;
import com.landi.logger.utils.SignCheck;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;




/**
 *
 * 14:58:01.024 [main] DEBUG com.exam.logexam.MainActivity: 这是一条debug级别日志
 * 14:58:01.043 [main] INFO  com.exam.logexam.MainActivity: 这是一条info级别日志
 * 14:58:01.057 [main] WARN  com.exam.logexam.MainActivity: 这是一条warn级别日志
 * 14:58:01.075 [main] ERROR com.exam.logexam.MainActivity: 这是一条error级别日志
 */
public class MainActivity extends AppCompatActivity {
    private final String TAG = "MainActivity";
    private LogcatUtil logcatUtil;
    private String realCer =
            "04:AD:77:B5:7B:D9:4A:C5:E7:99:" +
            "5F:76:52:C0:59:0C:A3:39:A5:D0";
    enum Constants{
        Constants_A(1),Constants_B(2),Constants_C(3);
        private int index;
        Constants(int id){
            index = id;
        }

        public int getIndex() {
            return index;
        }
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        logcatUtil = new LogcatUtil();
        logcatUtil.init();
        findViewById(R.id.btn_test1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                logcatUtil.info(MainActivity.class,"测试打印信息");
            }
        });
        findViewById(R.id.btn_test2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Logger logger = LoggerFactory.getLogger(MainActivity.class);
                logger.trace("这是一条trace级别日志");
                logger.debug("这是一条debug级别日志");
                logger.info("这是一条info级别日志");
                logger.warn("这是一条warn级别日志");
                logger.error("这是一条error级别日志");
            }
        });
        findViewById(R.id.btn_test3).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SignCheck signCheck = new SignCheck(MainActivity.this,
                        realCer);
                signCheck.check();
            }
        });
    }

}
